package com.rentplant.controller;

import com.alibaba.fastjson.JSONObject;
import com.rentplant.Pojo.admin;
import com.rentplant.service.impl.adminServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.event.ListDataEvent;
import java.sql.SQLOutput;
import java.util.List;

//@CrossOrigin
@RestController//让它知道这是controller
@RequestMapping("/admin")
public class adminController {
    @Autowired
    private adminServiceImp adminserviceimp;

    //    管理员登录

    @RequestMapping("/login")
    public List<admin> login(@RequestBody JSONObject req){
        try {
            String username = req.getString("username");
            String password = req.getString("password");

           return adminserviceimp.login(username);

//            return adminserviceimp.login(username);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
}
